using System;

namespace Aragorn.SOA.ORM.Lambda.Adapter
{
	internal class SqlServer2008Adapter : SqlServerAdapterBase, ISqlAdapter
	{
		public SqlServer2008Adapter()
		{
		}

		public string QueryStringPage(string source, string selection, string conditions, string order, int pageSize, int pageNumber)
		{
			object[] objArray = new object[] { selection, order, source, conditions };
			string str = string.Format("SELECT {0},ROW_NUMBER() OVER ({1}) AS RN FROM {2} {3}", objArray);
			return string.Format("SELECT TOP {0} * FROM ({1}) InnerQuery WHERE RN > {2} ORDER BY RN", pageSize, str, pageSize * (pageNumber - 1));
		}
	}
}